package com.zrt.controller;

import com.zrt.controller.util.Y;
import com.zrt.domain.Author;
import com.zrt.domain.InputAndOutput;
import com.zrt.service.ParseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;

@Controller
@RequestMapping("/latestParse")
public class ParseController {

    @Autowired
    private ParseService parseService;

    @PostMapping("/selectAllByAuthorOrTittleLike")
    public Y selectAllByAuthorOrTittleLike(@RequestBody Author author){
        return new Y(true,parseService.selectLikeAllAuthorAndCitation(author.getName()));
    }

    @PostMapping("/selectAndSaveIntoDB")
    public Y searchTheMessageAndSaveIntoDB(@RequestBody InputAndOutput inputAndOutput) throws IOException {
        return new Y(true,parseService.parseAuthor(inputAndOutput));
    }

}
